package node;

import structure.Identifiable;

/**
 *
 * @author Vojta
 */
public abstract class Node<T extends Identifiable> implements Insertable<T> {

    protected T element;

    public long getId() {
        return element.getId();
    }
    
    public T getElement() {
        return element;
    }
    
    public void setElement(T element) {
        this.element = element;
    }

    public void switchElements(Insertable i) {
        T temp = (T) i.getElement();
        i.setElement(getElement());
        setElement(temp);
    }

    public boolean equals(Insertable i) {
        return element.compareTo(i.getElement()) == 0;
    }

    public int compareTo(Object o) {
        return element.compareTo(((Node) o).element);
    }

    @Override
    public String toString() {
        return element.toString();
    }

}
